package router

import (
	"jgt-oper/src/context"
	"jgt-oper/src/web"

	"github.com/facebookgo/inject"
	"github.com/teambition/gear"
)

// WebEnterpriseMap 注册路由映射
func WebEnterpriseMap(g *inject.Graph, r *gear.Router) {
	a := new(web.Enterprise)
	err := g.Provide(&inject.Object{Value: a})
	if err != nil {
		panic(err)
	}

	r.Get("/enterprises/page", context.WrapContext(a.QueryPage))
	r.Get("/enterprises/select", context.WrapContext(a.QuerySelect)) //当前接口可能没有使用
	r.Get("/enterprises/category", context.WrapContext(a.QueryCategory))
	r.Get("/enterprises/enterprise-mark", context.WrapContext(a.QueryEnterpriseMark))
	r.Get("/enterprises/:id", context.WrapContext(a.Get))
	r.Post("/enterprises", context.WrapContext(a.Create))
	r.Put("/enterprises/:id", context.WrapContext(a.Update))
	r.Patch("/enterprises/:id/migration", context.WrapContext(a.Migration))
}
